<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:90:"D:\www\photo_album_bless\public_html/../application/wxapplet\view\singlepage\editjump.html";i:1544144729;s:69:"D:\www\photo_album_bless\application\wxapplet\view\shared\layout.html";i:1544144729;}*/ ?>
<!DOCTYPE html>
<html>


<!-- Mirrored from www.zi-han.net/theme/hplus/ by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:16:41 GMT -->
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <title>修改小程序</title>

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="stylesheet" href="/static/plugins/bootstrap-3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/plugins/font-awesome-4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/sys/css/style.min.css">
    <link rel="stylesheet" href="/static/plugins/bootstrap-table/bootstrap-table.css">
    <link rel="stylesheet" href="/static/plugins/dataTables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css">
    
    <script src="/static/plugins/jquery-1.12.4/jquery-1.12.4.min.js"></script>
    <script src="/static/plugins/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="/static/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/static/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/static/plugins/layui/layui.js"></script>
    <style>
        .text-red{color:red;}
        .text-green{color:#17bb46;}
        .text-orange{color:orange;}
        .text-yellow{color:#c7cd2f;}
        .text-blue{color:#0bb8c8;}
        .fixed-table-toolbar .bars, .fixed-table-toolbar .columns, .fixed-table-toolbar .search{margin-top:-45px;}
        .th-inner{color:#555;}
    </style>
    
    <style>
        #btn-upfile{position:relative;overflow:hidden;cursor:pointer;}
        #file{position:absolute;right:0;top:0;width:100px;height:100px;opacity:0; ilter:alpha(opacity=0);cursor:pointer;}
    </style>

</head>

<body class="gray-bg">
    
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form method="post" id="fmNew" class="form-horizontal">
                            <input type="hidden" name="base64pic" id="up_img" />
                            <input type="hidden" name="id" value="<?php echo $data['id']; ?>" />
                            <div class="form-group">
                                <label class="col-sm-2 control-label">名称：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="txtjump_name" name="jump_name" value="<?php echo $data['jump_name']; ?>" class="form-control" placeholder="跳转名称">
                                </div>
                            </div>                                    
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">小程序appid：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="txtappid" name="appid" value="<?php echo $data['appid']; ?>" class="form-control" placeholder="跳转目标小程序appid">
                                </div>
                            </div>                                    
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">跳转路径：</label>
                                <div class="col-sm-8">
                                    <input type="text" id="txtpath" name="path" value="<?php echo $data['path']; ?>" class="form-control" placeholder="跳转目标小程序路径">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">封面图片：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="cover_url" id="txtcover_url" value="<?php echo $data['cover_url']; ?>" class="form-control" placeholder="封面图片地址(上传或者直接填写外链)">                                    
                                </div>                                
                                <div class="col-sm-1">
                                    <span id="btn-upfile" class="btn btn-warning btn-sm" style="margin-bottom:0;padding:6px 8px;">
                                        <i class="glyphicon glyphicon-folder-open" style="padding-right:3px;"></i> 选择上传<input id="file" type="file" name="img">
                                    </span>
                                </div>
                                <div class="col-sm-1">
                                    <img id="previewImage" style="height:34px;">
                                </div>
                            </div>                        
                        </div>
                        <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-12 col-sm-offset-5">
                                    <button class="btn btn-primary" id="ok" type="button">提交</button>
                                    <button class="btn btn-white" id="cancel" type="button">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
    
    <script type="text/javascript">
         $(document).ready(function () {
            $("#ok").bind("click", Save);
            $("#cancel").bind("click", function () {
                parent.layer.close(parent.layer_edit_index);
            });

            var fileEls = document.getElementById('file');
            var upFileBtnEls = document.getElementById('btn-upfile');
            var fullBase64;
            var base64;
            fileEls.onchange = function(evt){
                if (!window.FileReader) return;
                var files = evt.target.files;
                for (var i = 0, f; f = files[i]; i++) {  
                    if (!f.type.match('image.*')) {  
                        continue;  
                    }

                    var reader = new FileReader();
                    reader.onload = (function(theFile) {
                        return function(e) {
                            document.getElementById('previewImage').src = e.target.result;
                            fullBase64 = e.target.result;
                            appendFile(fullBase64);
                        };
                    })(f);
                    reader.readAsDataURL(f);
                }
            };            
         })

         function appendFile(entry){
            var img = new Image();
            img.src = entry;
            
            img.onload = function () {
                var that = this;
                //设置图片宽高

                var w = 90;
                var h = 65;
        
                //生成canvas
                var canvas = document.createElement('canvas');
                var ctx = canvas.getContext('2d');
                $(canvas).attr({width : w, height : h});
                ctx.drawImage(that, 0, 0, w, h);
                base64 = canvas.toDataURL('image/jpeg', 0.9);   //1z 表示图片质量，越低越模糊。
                var up_img = document.getElementById('up_img');
                up_img.value = entry;
            }
        }

         function Save() {
            layui.use(['layer'], function(){
                var jumpname = $.trim($("input[name=jump_name]").val());
                if (jumpname.length == 0) {                
                    layer.tips('跳转名称不能为空！', 'input[name=jump_name]', { tips: [2, '#78BA32'] });
                    return false;
                }
            
                var appid = $.trim($("input[name=appid]").val());
                if (appid.length == 0) {                
                    layer.tips('目标小程序appid不能为空！', 'input[name=appid]', { tips: [2, '#78BA32'] });
                    return false;
                }

                var path = $.trim($("input[name=path]").val());
                if (path.length == 0) {                
                    layer.tips('目标小程序路径不能为空！', 'input[name=path]', { tips: [2, '#78BA32'] });
                    return false;
                }        
            
                var load_index = layer.load(0, { shade: false });
                $.ajax({
                    type: "post",
                    url: "<?php echo url('singlepage/editjump'); ?>?t=" + new Date(),
                    data: $("form").serialize(),
                    dataType: "json",
                    success: function (result) {
                        layer.close(load_index);
                        if (result.code == 0) {
                            layer.alert('修改成功！', function () {
                                if (typeof (parent.initTable) == "function")
                                    parent.initTable();
                                parent.layer.close(parent.layer_edit_index)
                            });
                        } else {
                            layer.alert(result.msg);
                        }
                    }
                });
            })
        }
    </script>

<!-- Mirrored from www.zi-han.net/theme/hplus/ by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:17:11 GMT -->
</html>